﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using eGov.SharePoint.MyPeeps.WebControls;


namespace eGov.SharePoint.MyPeeps.WebParts
{
    public enum FeedSource
    {
        Published,
        Consolidated
    }

    public abstract class ActivityUpdatesWebPart : System.Web.UI.WebControls.WebParts.WebPart
    {
        protected bool _error = false;
        private int initialFeedsCount = 10;
        private int viewMoreCount = 10;
        private bool viewMore = true;
        private FeedSource feedsSource;

        [System.Web.UI.WebControls.WebParts.WebBrowsable(true),
       System.Web.UI.WebControls.WebParts.WebDisplayName("Initial Feeds Count"),
       System.Web.UI.WebControls.WebParts.WebDescription("Initial number of feeds to display"),
       System.Web.UI.WebControls.WebParts.Personalizable(
       System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared),
       System.ComponentModel.Category("Miscellaneous"),
       System.ComponentModel.DefaultValue(10)]
        public int InitialFeedsCount
        {
            get
            {
                return initialFeedsCount;
            }

            set
            {
                initialFeedsCount = value;
            }
        }


        [System.Web.UI.WebControls.WebParts.WebBrowsable(true),
       System.Web.UI.WebControls.WebParts.WebDisplayName("View More Items Count"),
       System.Web.UI.WebControls.WebParts.WebDescription(""),
       System.Web.UI.WebControls.WebParts.Personalizable(
       System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared),
       System.ComponentModel.Category("Miscellaneous"),
       System.ComponentModel.DefaultValue(10)]
        public int ViewMoreCount
        {
            get
            {
                return viewMoreCount;
            }

            set
            {
                viewMoreCount = value;
            }
        }


        [System.Web.UI.WebControls.WebParts.WebBrowsable(true),
       System.Web.UI.WebControls.WebParts.WebDisplayName("View More"),
       System.Web.UI.WebControls.WebParts.WebDescription("Link to load extra feeds"),
       System.Web.UI.WebControls.WebParts.Personalizable(
       System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared),
       System.ComponentModel.Category("Miscellaneous"),
       System.ComponentModel.DefaultValue(true)]
        public bool ViewMore
        {
            get
            {
                return viewMore;
            }

            set
            {
                viewMore = value;
            }
        }

        public ActivityUpdatesWebPart()
        { }

        protected override void RenderContents(HtmlTextWriter writer)
        {
            base.RenderContents(writer);
        }

        /// <summary>
        /// Clear all child controls and add an error message for display.
        /// </summary>
        /// <param name="ex"></param>
        protected void HandleException(Exception ex)
        {
            this._error = true;
            this.Controls.Clear();
            this.Controls.Add(new LiteralControl(ex.Message));
        }
    }
}
